package com.hsav.kcxb.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.hsav.kcxb.R;
import com.zhy.autolayout.utils.AutoUtils;

/**
 * Created by zhao on 2017/2/5.
 */

public class MsgAdapter extends BaseAdapter {

    private final Context mContext;
    private final LayoutInflater mInflater;

    public MsgAdapter(Context context){
        this.mContext = context;
        this.mInflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return 10;
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        MyViewHolder myViewHolder = null;
        if(convertView==null){
            convertView = mInflater.inflate(R.layout.item_msg_view,parent,false);
            myViewHolder = new MyViewHolder();
            myViewHolder.headImg = (ImageView)convertView.findViewById(R.id.img_msg_head);
            myViewHolder.nameTx = (TextView)convertView.findViewById(R.id.tx_msg_name);
            myViewHolder.titleTx=(TextView)convertView.findViewById(R.id.tx_msg_content);
            convertView.setTag(myViewHolder);
            AutoUtils.autoSize(convertView);
        }else {
            myViewHolder = (MyViewHolder) convertView.getTag();
        }
        return convertView;
    }

    private class MyViewHolder{
        ImageView headImg;
        TextView nameTx;
        TextView titleTx;

    }
}
